package com.study.designmodes.service.executor.businessTask;

import com.alibaba.fastjson.JSONObject;
import com.study.designmodes.enums.WebsiteCodeEnum;
import com.study.designmodes.request.BusinessObjectRequest;
import com.study.designmodes.service.executor.AbstractExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 抽象业务任务执行人
 *
 * @author yangyanbin
 * @date 2023/02/01
 * @since 20230201
 */
@Slf4j
@Component
public class BusinessTaskAbstractExecutor extends AbstractExecutor<BusinessObjectRequest> {
    /**
     * 处理过程
     *
     * @param businessObjectRequest 处理参数
     */
    @Override
    protected void process(BusinessObjectRequest businessObjectRequest) {
        log.info("任务开始处理，请求参数--》{}", JSONObject.toJSONString(businessObjectRequest));
    }

    /**
     * 初始化
     *
     * @param businessObjectRequest 处理参数
     */
    @Override
    protected void init(BusinessObjectRequest businessObjectRequest) {
        log.info("任务开始初始化，请求参数--》{}", JSONObject.toJSONString(businessObjectRequest));

    }

    /**
     * 结束
     */
    @Override
    protected void finish() {

    }

    /**
     * 自定义方法
     */
    protected void diyFunction(BusinessObjectRequest businessObjectRequest, WebsiteCodeEnum websiteCodeEnum) {
        log.info("自定义方法做一些业务处理，请求参数--》{}", JSONObject.toJSONString(businessObjectRequest));
        log.info("自定义方法做一些业务处理(业务code)，请求参数--》{}", JSONObject.toJSONString(websiteCodeEnum));


    }
}
